package cn.yishuai.ai.spring_mcp_server.tools;


import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Component;

@Component
public class LlmTools {

    private final ChatClient chatClient;

    public LlmTools(ChatClient chatClient) {
        this.chatClient = chatClient;
    }

    @Tool(name = "llmGenerate", description = "使用本地 Ollama 模型生成文本内容")
    public String llmGenerate(
            @ToolParam(description = "生成任务说明，例如：'总结以下内容'") String instruction,
            @ToolParam(description = "可选输入内容") String input) {

        String prompt = instruction + (input != null && !input.isBlank() ? "\n\n" + input : "");
        return chatClient.prompt(prompt).call().content();
    }
}